package zhaolongli_Boundary;

import java.awt.Color;
import java.awt.Font;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;

import zhaolongli_Controller.EdgeController;
import zhaolongli_Entity.Model;


/** main panel that holds the labels and the Drawing Canvas */

public class MyPanel extends JPanel {

	Model m;
	DrawingCanvas lineView = null;
	
	/**
	 * Create the panel.
	 */
	public MyPanel(Model m) {
		this.m = m;
		initialized();

	}

	/**
	 * Initialized the panel.
	 */
	void initialized(){


		
		/* initialized Drawing Canvas */
		lineView = getDrawingCanvas();
		lineView.setBackground(Color.WHITE);
		lineView.setBounds(50, 150, 600, 400);
		
		// Initialized EdgeController
		EdgeController ec = new EdgeController(m, lineView);
		lineView.addMouseListener(ec);
		lineView.addMouseMotionListener(ec);			
		this.add(lineView);
		
		//Label the App
		JLabel lblTitle = new JLabel("DECISION LINES (PERSONAL VERSION)");
		lblTitle.setFont(new Font("Lucida Grande", Font.BOLD, 20));
		lblTitle.setBounds(243, 18, 415, 33);
		this.add(lblTitle);
		
		//the Question Field
		JTextArea questionField = new JTextArea();
		questionField.setEditable(false);
		questionField.setBackground(UIManager.getColor("Button.background"));
		questionField.setText(m.getQuestion());
		questionField.setLineWrap(true);
		questionField.setBounds(50, 63, 600, 35);
		this.add(questionField);
		
		JLabel lblN = new JLabel("N = "+ m.getN());
		lblN.setFont(new Font("MT Extra", Font.BOLD, 16));
		lblN.setBounds(750, 320, 120, 20);
		this.add(lblN);
		
		JLabel lblM = new JLabel("M = "+ m.getM());
		lblM.setFont(new Font("MT Extra", Font.BOLD, 16));
		lblM.setBounds(750, 350, 120, 20);
		this.add(lblM);
			
		
	}
	
	/**
	 * Get the Lines View
	 */
	public DrawingCanvas getDrawingCanvas(){
		if(this.lineView == null){
			this.lineView = new DrawingCanvas(m);
			return this.lineView;
		}
		return lineView;
	}
	

	
}
